/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package snake.core.listeners;

import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import snake.gameplay.Position;
import snake.gameplay.Snake;

/**
 *
 * @author Fein
 */
public class SnakeActionListener extends BaseSnakeListener implements ActionListener {

    private static final Position POSITION_CHANGE_UP = new Position(0, -1);
    private static final Position POSITION_CHANGE_DOWN = new Position(0, 1);
    private static final Position POSITION_CHANGE_LEFT = new Position(-1, 0);
    private static final Position POSITION_CHANGE_RIGTH = new Position(1, 0);

    public SnakeActionListener() {
    }
    
    public SnakeActionListener(Snake snake, Container container) {
        super(snake, container);
    }
    //   private static int movement = 0;

    public void actionPerformed(ActionEvent e) {
        switch (snake.getMovementDirection()) {
            case KeyEvent.VK_UP:
                changePosition(POSITION_CHANGE_UP);
                break;
            case KeyEvent.VK_DOWN:
                changePosition(POSITION_CHANGE_DOWN);
                break;
            case KeyEvent.VK_LEFT:
                changePosition(POSITION_CHANGE_LEFT);
                break;
            case KeyEvent.VK_RIGHT:
                changePosition(POSITION_CHANGE_RIGTH);
                break;
            default:

        }
//        movement++;
//        container.getComponent(6+movement).setBackground(Color.red);
//        if (movement!=0) {
//            container.getComponent(6+movement-1).setBackground(Color.LIGHT_GRAY);
//        }
    }
}
